home *** CD-ROM | disk | FTP | other *** search
- /*
- File: StorageClassUTDriver.c
-
- Contains: This file contains the globally exported symbols and
- entry points into the Storage Class UT driver.
-
- Version: 1.1
-
- Copyright: © 1998-1999 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include "StorageClassUTDriver.h"
- #include "StorageClassUTFunctions.h"
- #include "SampleStorageVersion.h"
-
- //----------------------------------------------------------------------------------
- // The Driver Description structure -
- // This structure provides the Device Manager with information about our native driver
- //----------------------------------------------------------------------------------
-
- DriverDescription TheDriverDescription =
- {
- kTheDescriptionSignature,
- kInitialDriverDescriptor,
-
- // DriverType
- "\p.StorageClass_UT_Driver",
- kStorageHexMajorVers, kStorageHexMinorVers, kStorageReleaseStage, kStorageCurrentRelease,
-
- // DriverOSRuntimeInfo
- 0
- | (1 * kDriverIsLoadedUponDiscovery) // Loader runtime options
- | (1 * kDriverIsOpenedUponLoad) // Opened when loaded
- | (0 * kDriverIsUnderExpertControl) // No I/O expert to handle loads/opens
- | (0 * kDriverIsConcurrent) // Not concurrent yet
- | (0 * kDriverQueuesIOPB), // Not internally queued yet
- "\p.StorageClass_UT_Driver", // Str31 driverName (OpenDriver param)
- 0, 0, 0, 0, 0, 0, 0, 0, // UInt32 driverDescReserved[8]
-
- // DriverOSService
- 1, // ServiceCount nServices
-
- // DriverServiceInfo
- kServiceCategoryNdrvDriver, // OSType serviceCategory
- kNdrvTypeIsGeneric, // OSType serviceType
- kStorageHexMajorVers, kStorageHexMinorVers, kStorageReleaseStage, kStorageCurrentRelease
- };
-
- //----------------------------------------------------------------------------------
- // The DoDriverIO Function -
- // This function is the only entry to our driver from the Device Manager
- //----------------------------------------------------------------------------------
-
- OSStatus DoDriverIO( AddressSpaceID addressSpaceID,
- IOCommandID ioCommandID,
- IOCommandContents ioCommandContents,
- IOCommandCode ioCommandCode,
- IOCommandKind ioCommandKind)
- {
- OSStatus status;
-
- IfDebugging("\pIn my driver");
- /*
- Note: Initialize, Open, KillIO, Close, and Finalize are either synchronous
- or immediate. Read, Write, Control, and Status may be immediate,
- synchronous, or asynchronous.
- */
- switch (ioCommandCode)
- {
- case kInitializeCommand: /* Always immediate */
- status = DriverInitializeCmd (addressSpaceID, ioCommandContents.initialInfo);
- break;
- case kFinalizeCommand: /* Always immediate */
- status = DriverFinalizeCmd (ioCommandContents.finalInfo);
- break;
- case kSupersededCommand: /* Always immediate */
- status = DriverSupersededCmd (ioCommandContents.supersededInfo);
- break;
- case kReplaceCommand: /* Always immediate, replace an old driver */
- status = DriverReplaceCmd (addressSpaceID, ioCommandContents.replaceInfo);
- break;
- case kOpenCommand: /* Always immediate */
- status = DriverOpenCmd (addressSpaceID, ioCommandContents.pb);
- break;
- case kCloseCommand: /* Always immediate */
- status = DriverCloseCmd (ioCommandContents.pb);
- break;
- case kControlCommand:
- status = DriverControlCmd (addressSpaceID, ioCommandID, ioCommandKind, ioCommandContents.pb);
- break;
- case kStatusCommand:
- status = DriverStatusCmd (addressSpaceID, ioCommandID, ioCommandKind, ioCommandContents.pb);
- break;
- case kReadCommand:
- status = DriverReadCmd ( addressSpaceID, ioCommandID, ioCommandKind, ioCommandContents.pb);
- break;
- case kWriteCommand:
- status = DriverWriteCmd ( addressSpaceID, ioCommandID, ioCommandKind, ioCommandContents.pb);
- break;
- case kKillIOCommand: /* Always immediate */
- status = DriverKillIOCmd (ioCommandContents.pb);
- break;
- default:
- status = paramErr;
- break;
- }
-
- return FinishCommandProcessing(ioCommandID, ioCommandKind, status);
- }
-
- OSStatus FinishCommandProcessing(IOCommandID ioCommandID,IOCommandKind ioCommandKind,OSStatus incomingStatus)
- {
- OSStatus status = incomingStatus;
-
- IfDebugging("\pFinishCommandProcessing");
-
- if ((ioCommandKind & kImmediateIOCommandKind) != 0)
- {
- /* Immediate commands return the operation status and don't call IOCommandIsComplete */
- IfDebugging("\pImmd cmd complete");
- }
- else if (incomingStatus == ioInProgress)
- {
- IfDebugging("\pincomingStatus == ioInProgress");
- /* Perform the action and call IOCommandIsComplete at some later time */
- status = noErr;
- }
- else
- {
- IfDebugging("\pDo Command Is Complete");
- status = IOCommandIsComplete (ioCommandID, incomingStatus);
- }
-
- IfDebugging("\pExit FinishCommandProcessing");
- return (status);
- }
-
-